package com.hw.backapi.controller;

import com.hw.backapi.service.DoctorService;
import com.hw.common.annotation.MyLogAdmin;
import com.hw.common.contants.UrlContants;
import com.hw.model.common.BaseResult;
import com.hw.model.dto.doctor.DetailQueryDTO;
import com.hw.model.dto.doctor.DoctorAuthDTO;
import com.hw.model.dto.doctor.DoctorDelDTO;
import com.hw.model.dto.doctor.DoctorSaveDTO;
import com.hw.model.dto.doctor.DoctorUpdateDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author lipeng
 * @description 医生
 * @date 2023/3/9 13:15
 */
@RestController
public class DoctorController {

    @Autowired
    DoctorService doctorServiceImpl;

    /**
     * @descrition 医生列表
     * @author lipeng
     * @date 2023/3/9
     * @param
     * @return com.hw.model.common.BaseResult
     */
    @PostMapping(UrlContants.DOCTOR_LIST)
    public BaseResult doctorList(
            @RequestBody DetailQueryDTO detailQueryDTO
    ){
        return BaseResult.ok(doctorServiceImpl.detailListPage(detailQueryDTO));
    }

    /**
     * @descrition 医生列表手机号
     * @author lipeng
     * @date 2023/3/9
     * @param
     * @return com.hw.model.common.BaseResult
     */
    @PostMapping(UrlContants.DOCTOR_LIST_PHONE)
    public BaseResult doctorListPhone(
            @RequestBody DetailQueryDTO detailQueryDTO
    ){
        return BaseResult.ok(doctorServiceImpl.detailPhoneList(detailQueryDTO));
    }

    /**
     * @descrition 医生添加
     * @author lipeng
     * @date 2023/3/8
     * @param
     * @return com.hw.model.common.BaseResult
     */
    @PostMapping(UrlContants.DOCTOR_ADD)
    @MyLogAdmin(label = "医生添加")
    public BaseResult doctorAdd(
           @Valid @RequestBody DoctorSaveDTO doctorSaveDTO
    ){
        doctorServiceImpl.addDoctor(doctorSaveDTO);
        return BaseResult.ok();
    }


    /**
     * @descrition 医生删除
     * @author lipeng
     * @date 2023/3/8
     * @param
     * @return com.hw.model.common.BaseResult
     */
    @MyLogAdmin(label = "医生删除")
    @PostMapping(UrlContants.DOCTOR_DEL)
    public BaseResult doctorDel(
            @Valid @RequestBody DoctorDelDTO doctorDelDTO
    ){
        doctorServiceImpl.delDoctor(doctorDelDTO);
        return BaseResult.ok();
    }


    /**
     * @descrition 医生修改
     * @author lipeng
     * @date 2023/3/8
     * @param
     * @return com.hw.model.common.BaseResult
     */
    @MyLogAdmin(label = "医生修改")
    @PostMapping(UrlContants.DOCTOR_UPDATE)
    public BaseResult doctorUpdate(
            @RequestBody DoctorUpdateDTO doctorUpdateDTO
    ){
        doctorServiceImpl.updateDoctor(doctorUpdateDTO);
        return BaseResult.ok();
    }

    /**
     * @descrition 医生授权
     * @author lipeng
     * @date 2023/3/8
     * @param
     * @return com.hw.model.common.BaseResult
     */
    @MyLogAdmin(label = "医生授权")
    @PostMapping(UrlContants.DOCTOR_ADD_AUTH)
    public BaseResult doctorAddAuth(
            @RequestBody DoctorAuthDTO doctorAuthDTO
    ){
        doctorServiceImpl.doctorAddAuth(doctorAuthDTO);
        return BaseResult.ok();
    }

    /**
     * @descrition 医生取消授权
     * @author lipeng
     * @date 2023/3/8
     * @param
     * @return com.hw.model.common.BaseResult
     */
    @MyLogAdmin(label = "医生取消授权")
    @PostMapping(UrlContants.DOCTOR_CANCEL_AUTH)
    public BaseResult doctorCancelAuth(
            @RequestBody DoctorAuthDTO doctorAuthDTO
    ){
        doctorServiceImpl.doctorCancelAuth(doctorAuthDTO);
        return BaseResult.ok();
    }

}
